#ifndef  __WIDGET_H__
#define  __WIDGET_H__

#include <stdint.h>
#include <stdio.h>


typedef enum{
    WIDGET_TYPE_BUTTON,
    WIDGET_TYPE_TEXTBOX,
    WIDGET_TYPE_SW,
    WIDGET_TYPE_BAR,
    WIDGET_TYPE_BAT,
    WIDGET_TYPE_ICON,
    WIDGET_TYPE_TIMER,
    WIDGET_TYPE_METER,
    WIDGET_TYPE_MOUSE,
}WIDGET_TYPE;




enum TS_EVENT{
    TS_EV_UP           = (1 << 0),
    TS_EV_DOWN         = (1 << 1),
    TS_EV_LEFT         = (1 << 2),
    TS_EV_RIGHT        = (1 << 3),
    TS_EV_RELEASE      = (1 << 4),
    TS_EV_LONG_PRESS   = (1 << 5),
    TS_EV_SHORT_PRESS  = (1 << 6),
    TS_EV_NULL         = (1 << 7),
};



struct window_t{
    int table_index;
    int16_t x,y;
    uint16_t w,h;
    uint16_t hide;
    uint16_t move:1;
    uint16_t backcolor;
    uint32_t event;
    char *name;
    void (*cb)(struct window_t *,uint8_t,int16_t,int16_t);
    void *list[8];
};


struct genery_param_t{
    WIDGET_TYPE type;
    uint16_t id;
    int16_t x,y;
    int16_t mirror_x,mirror_y;
    uint16_t w,h;
    uint16_t frame_size;//边框大小
    uint16_t frame_color;//边框颜色
    uint16_t bc,fc;//backgrang-color/font-color
    uint16_t value;
    int16_t scroll;
    uint16_t color_on,color_off;
    uint16_t color;
    int max,min;
    struct window_t *page;
    char *name;
    char *text;
    void (*cb_widget)(struct genery_param_t *,uint8_t ev,int16_t,int16_t);
    void (*cb_event)(struct genery_param_t *,enum GUI_EVENT);
    const struct font_t *font;
};

void ts_event_input(uint8_t ev,int16_t,int16_t);
void window_create(struct window_t *window,int16_t x,int16_t y,uint16_t w,uint16_t h);
void window_add(struct window_t *window, struct genery_param_t *param);
void window_show(struct window_t *window);


#endif